﻿using System;

namespace Maltose.Aliyun.RocketMQ
{
    /// <summary>
    /// 消息队列生产者
    /// </summary>
    public class MessageQueueProducer : MessageQueueHostSetting
    {


        //锁
        static readonly object _lock = new object();

        /// <summary>
        /// 
        /// </summary>
        static Producer _Producer;

        /// <summary>
        /// 访问对象
        /// </summary>
        Producer producer
        {
            get
            {
                if (_Producer == null)
                {
                    lock (_lock)
                    {
                        if (_Producer == null)
                        {
                            _Producer = ONSFactory.GetInstance().CreateProducer(factoryInfo);
                            _Producer.Start();
                            return _Producer;
                        }
                    }
                }
                return _Producer;
            }
        }

        public MessageQueueProducer()
        {
            Message msg = new Message(factoryInfo.GetPublishTopics(), "tagA", "Example message body");
            producer.Send(msg);
            producer.Shutdown();
        }


        //MessageQueueConsumer
        //MessageQueueSubscribe
        public void A()
        {

            // 启动客户端实例

        }

        public void SendMessage(string tags, string content)
        {

        }
    }
}
